package model

import (
	"errors"
	"fmt"
	"server/component"
)

type MsgLogRecord struct {
	Id          int `json:"id"`
	Msg         string
	Sender      string
	Receiver    string
	Type        int
	CreatedTime int `gorm:"autoCreateTime"`
}

func (MsgLogRecord) TableName() string {
	return "msg_log"
}

const (
	MsgLogPublic  = 1
	MsgLogPrivate = 2
	MsgLogGroup   = 3
)

func AddMsgLog(data *MsgLogRecord) error {
	result := component.Db.Create(data)
	if result.Error != nil {
		fmt.Println(result.Error)
		return errors.New("add error")
	}
	return nil
}
